﻿using System;
using NUnit.Framework;
using TechTalk.SpecFlow;
using CalculatorApi.Core.Services;

namespace CalculatorApi.Stories.Steps
{
    [Binding]
    public class AdditionSteps
    {
        [Given(@"The CalculatorApi has not recieved any inputs")]
        public void GivenTheCalculatorApiHasNotRecievedAnyInputs()
        {
            var calculator = new CalculatorService();

            ScenarioContext.Current.Set(calculator);
        }
        
        [Given(@"It gets (.*) as a parameter to the AddMethod")]
        public void GivenItGetsAsAParameterToTheAddMethod(decimal p0)
        {
            var calculator = ScenarioContext.Current.Get<CalculatorService>();
            calculator.Add(p0);
        }
        
        [Given(@"The CalculatorApi has recieved a starting value of (.*)")]
        public void GivenTheCalculatorApiHasRecievedAStartingValueOf(decimal p0)
        {
            var calculator = new CalculatorService(p0);
            ScenarioContext.Current.Set(calculator);
        }
        
        [When(@"It returns the result")]
        public void WhenItReturnsTheResult()
        {
            var calculator = ScenarioContext.Current.Get<CalculatorService>();
            var result = calculator.Result();

            ScenarioContext.Current.Set(result);
        }

        [Then(@"the result should be (.*)")]
        public void ThenTheResultShouldBe(decimal p0)
        {
            var result = ScenarioContext.Current.Get<decimal>();
            Assert.AreEqual(p0, result);
        }

    }
}
